package com.tbit.main.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.Objects;

/**
 * @author yee_
 * @version 1.0
 * @date 2023/2/19 22:00
 */
@Data
public class PowerChangeMonitorConfig {

    /**
     * 区域id
     */
    @TableId(type = IdType.INPUT)
    private Integer accountId;
    /**
     * 馈电最大值
     */
    private Integer powerFeedMax;
    /**
     * 低电最小值
     */
    private Integer powerLowMin;
    /**
     * 低电最大值
     */
    private Integer powerLowMax;
    /**
     * 中电最小值
     */
    private Integer powerMiddleMin;
    /**
     * 中电最大值
     */
    private Integer powerMiddleMax;
    /**
     * 高电最小值
     */
    private Integer powerHighMin;

    /**
     * 闲置区间 短时最小值
     */
    private Integer idleShortMin;
    /**
     * 闲置区间 短时最大值
     */
    private Integer idleShortMax;
    /**
     * 闲置区间 中时最小值
     */
    private Integer idleMiddleMin;
    /**
     * 闲置区间 中时最大值
     */
    private Integer idleMiddleMax;
    /**
     * 闲置区间 长时最大值
     */
    private Integer idleLongMin;

    /**
     * 长时起始时长
     */
    private Integer noOrderLong;

    /**
     * 中时起始时长
     */
    private Integer noOrderMiddleMin;

    /**
     * 中时截止时长
     */
    private Integer noOrderMiddleMax;

    /**
     * 短时起始时长
     */
    private Integer noOrderShortMin;

    /**
     * 短时截止时长
     */
    private Integer noOrderShortMax;

    /**
     * 长时起始时长
     */
    private Integer longOrder;

    /**
     * 中时起始时长
     */
    private Integer longOrderMiddleMin;

    /**
     * 中时截止时长
     */
    private Integer longOrderMiddleMax;

    /**
     * 短时起始时长
     */
    private Integer longOrderShortMin;

    /**
     * 短时起始时长
     */
    private Integer longOrderShortMax;

    public PowerChangeMonitorConfig(Integer accountId) {
        putDefaultValue(accountId);
    }

    public void putDefaultValue(Integer accountId) {
        this.accountId = accountId;
        this.powerFeedMax = -1;
        this.powerLowMin = 0;
        this.powerLowMax = 20;
        this.powerMiddleMin = 21;
        this.powerMiddleMax = 40;
        this.powerHighMin = 41;
        this.idleShortMin = 6;
        this.idleShortMax = 24;
        this.idleMiddleMin = 25;
        this.idleMiddleMax = 72;
        this.idleLongMin = 73;
        this.noOrderShortMin = 24;
        this.noOrderShortMax = 49;
        this.noOrderMiddleMin = 49;
        this.noOrderMiddleMax = 73;
        this.noOrderLong = 73;
        this.longOrderShortMax = 7;
        this.longOrderShortMin = 1;
        this.longOrderMiddleMin = 7;
        this.longOrderMiddleMax = 13;
        this.longOrder = 13;
    }

    /**
     * 校验无订单和超时长是否有默认值
     */
    public void checkNull(){
        this.noOrderShortMin = Objects.isNull(this.noOrderShortMin) ? 24 : this.noOrderShortMin;
        this.noOrderShortMax = Objects.isNull(this.noOrderShortMax) ? 49 : this.noOrderShortMax;
        this.noOrderMiddleMin = Objects.isNull(this.noOrderMiddleMin) ? 49 : this.noOrderMiddleMin;
        this.noOrderMiddleMax = Objects.isNull(this.noOrderMiddleMax) ? 73 : this.noOrderMiddleMax;
        this.noOrderLong = Objects.isNull(this.noOrderLong) ? 73 : this.noOrderLong;
        this.longOrderShortMax = Objects.isNull(this.longOrderShortMax) ? 7 : this.longOrderShortMax;
        this.longOrderShortMin = Objects.isNull(this.longOrderShortMin) ? 1 : this.longOrderShortMin;
        this.longOrderMiddleMin = Objects.isNull(this.longOrderMiddleMin) ? 7 : this.longOrderMiddleMin;
        this.longOrderMiddleMax = Objects.isNull(this.longOrderMiddleMax) ? 13 : this.longOrderMiddleMax;
        this.longOrder = Objects.isNull(this.longOrder) ? 13 : this.longOrder;
    }


}
